Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional Git hook to run lint before pushing #175

Closed
wants to merge 2 commits into from

Conversation

mcmire
Copy link
Contributor

@mcmire mcmire commented Feb 15, 2023

Say you've completed work on your branch and now you want to create a pull request, but unbeknownst to you, some code doesn't pass the lint step. It's nice to address those lint violations now, otherwise you will end up waiting until CI runs and puts an X on your PR.

Some of us on the Shared Libraries team have been testing using a Git hook to run the lint step in the core repo, and it has been working well so far, so this commit brings the same idea over. The Git hook runs before each push, allowing commit creation to remain speedy, and it is a completely optional part of setting up your development environment. You can install it by running yarn sync-git-hooks.

@mcmire mcmire requested a review from a team as a code owner February 15, 2023 18:13
Say you've completed work on your branch and now you want to create a
pull request, but unbeknownst to you, some code doesn't pass the lint
step. It's nice to address those lint violations now, otherwise you will
end up waiting until CI runs and puts an X on your PR.

Some of us on the Shared Libraries team have been testing using a Git
hook to run the lint step in the `core` repo, and it has been working
well so far, so this commit brings the same idea over. The Git hook runs
before each push, allowing commit creation to remain speedy, and it is a
completely optional part of setting up your development environment. You
can install it by running `yarn sync-git-hooks`.
@socket-security
Copy link

socket-security bot commented Feb 15, 2023

New dependency changes detected. Learn more about Socket for GitHub ↗︎


🚨 Potential security issues found in this pull request. To accept the risk, merge this PR and you will not be notified again.

Bot Commands

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of package-name@version specifiers. e.g. @SocketSecurity ignore [email protected] bar@* or ignore all packages with @SocketSecurity ignore-all

📜 Install scripts

Install scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.

Packages should not be running non-essential scripts during install and there are often solutions to problems people solve with install scripts that can be run at publish time instead.

Package Script field Source
[email protected] (added) postinstall package.json
Pull request alert summary
Issue Status
Install scripts ⚠️ 1 issue
Native code ✅ 0 issues
Bin script shell injection ✅ 0 issues
Unresolved require ✅ 0 issues
Invalid package.json ✅ 0 issues
HTTP dependency ✅ 0 issues
Git dependency ✅ 0 issues
Potential typo squat ✅ 0 issues
Known Malware ✅ 0 issues
Telemetry ✅ 0 issues
Protestware/Troll package ✅ 0 issues

📊 Modified Dependency Overview:

➕ Added Package Capability Access +/- Transitive Count Publisher
[email protected] filesystem +0 toplenboren

"test": "jest && jest-it-up",
"test:watch": "jest --watch"
},
"simple-git-hooks": {
"pre-push": "yarn lint"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer this to be pre-commit. If you separate the commands a little bit, it could run eslint --fix and prettier --write as well, using lint-staged. See snaps-monorepo for example.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If changing to pre-commit, maybe we can add a note in README.md on the existence of git commit -n to make onboarding smoother?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I definitely agree with using some kind of mechanism to lint fewer files. That would go a long way in improving the developer experience, I believe, and would possibly remove the concerns I have about using a pre-commit hook. lint-staged requires that you use a .prettierignore file which I'd like to avoid. I figured out some other way of doing this for another project, however, so I'll see if I can find that.

This comment was marked as spam.

@mcmire
Copy link
Contributor Author

mcmire commented Oct 28, 2024

I am going to close this as it's very stale now, and this isn't a high priority.

@mcmire mcmire closed this Oct 28, 2024
Jamstar00

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants